<?php
/**
 * 管理员
 *
 * @author      zlc
 * @version     1.0
 */

namespace App\Models;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
//use Tymon\JWTAuth\Contracts\JWTSubject;
use DateTimeInterface;
class Admin extends Authenticatable
{
    use Notifiable;
//    use HasRoles;

    protected $table = 'pd_admins';

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['username','password','status','last_ip'];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * 获取JWT标识符
     */
    public function getJWTIdentifier()
    {
        return $this->getKey();
    }

    /**
     * 获取JWT自定义声明
     */
    public function getJWTCustomClaims()
    {
        return [
            'role' => $this->role,  // 示例：添加用户角色到token
            // 可以添加更多自定义声明
        ];
    }

    protected function serializeDate(DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

}
